﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dao
{
    public interface IRepository<T> where T : class
    {
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="id">ID</param>
        /// <returns>实体</returns>
        T Get(object id);

        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="id">ID</param>
        /// <returns>实体</returns>
        T Load(object id);

        /// <summary>
        /// 插入实体
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns>ID</returns>
        object Save(T entity);

        /// <summary>
        /// 修改实体
        /// </summary>
        /// <param name="entity">实体</param>
        void Update(T entity);

        /// <summary>
        /// 修改或保存实体
        /// </summary>
        /// <param name="entity">实体</param>
        void SaveOrUpdate(T entity);

        /// <summary>
        /// 删除实体
        /// </summary>
        /// <param name="id">ID</param>
        void Delete(object id);

         /// <summary>
        /// 删除实体
        /// </summary>
        /// <param name="entity">实体</param>
        void Delete(T entity);

        /// <summary>
        /// 删除实体
        /// </summary>
        /// <param name="IDList">ID集合</param>
        void Delete(IList<T> IDList);

        /// <summary>
        /// 延迟加载类集合
        /// </summary>
        /// <returns></returns>
        IQueryable<T> LoadAll();

        /// <summary>
        /// 将对象保存到数据库
        /// </summary>
        void Flush();

    }
}
